extends BatScene

signal onDeathWord(cha)
signal onCharaSumm(cha)

var mark = "VE"
func addObj(obj:Obj,cell = null):
	if cell == null:
		cell = obj.cell
	else:
		obj.cell = cell
		
	var objV
	if obj.get("staticPic") == null:
		#加载动态角色CharaV
		objV = sys.get_node("VEBase").charaV.instance()
	else:
		#加载静态角色CharaV
		objV = preload("res://!ve/base/tscn/chara/charaVS.tscn").instance()
	
	objMap.add_child(objV)
	if addObjVE(obj,cell) == false:return
	objNumDs[obj.team] += 1
	objV.connect("onDelEnd",self,"rDelEnd")
	objV.init(obj)
	objV.setProcess(false)
	newEff("e_zhao",objV.position)
	return obj
	
func addObjVE(obj,cell = Vector2.ZERO):
	cell = getNullCell(cell)
	if newInMat(cell,obj) :
		obj.inScene(self)
		objs.addItem(obj)
		emit_signal("onAddObj",obj)
	else:
		obj.del()
		return false

func setIsBattle(val):
	isBattle = val
	if objMap == null:
		return
	for i in objMap.get_children():
		if i is CharaV : 
			i.setProcess(val)
			if i.chara.team == sys.player.team:
				i.isDrag = !val

func del():
	Engine.iterations_per_second = 60
	.del()

#获得所有活着的友军
func getAllAllys(team = null):
	if team == null:
		team = sys.game.player.team
	var list = []
	for i in mat.values():
		if i != null and i.team == team and not i.isDeath:
			list.append(i)
	return list
#获得所有活着的敌人
func getAllEnemys(team = null):
	if team == null:
		team = sys.game.player.team
	var list = []
	for i in mat.values():
		if i != null and i.team != team and not i.isDeath:
			list.append(i)
	return list

#敌方场上是否全是隐身角色
func isAllYingCha(chas = null, team = null):
	if team == null:
		team = sys.game.player.team
	if chas == null:
		chas = getAllEnemys(team)
	for i in chas:
		if i.yingTime <= 0:
			return false
	return true

#获得目标朝向指定长度的所有单位
func getDirectLineChas(from, to, length = 15):
	pass
#获得所有单元格
func getAllCells():
	return mat.keys()
